﻿/********************************************************************************/
// <copyright file="EventModels.cs" company="Asia E-Business Solutions">
//     Copyright © 2012. All right reserved
// </copyright>
// <history>
//     <change who="Phuoc Le" date="02/01/2013 4:24:27 PM">Created</change>
// </history>
/********************************************************************************/

using System;
using System.ComponentModel;
using System.Text;
using System.Text.RegularExpressions;
using JLL.China.Model.DTO;
using JLL.China.Model;
using System.Collections.Generic;
using System.Collections;

namespace JLL.China.Web.Areas.Portal.Models
{
    public class EventsModel
    {
        public IList<Event> Events { get; set; }

        public EventSearchOrder OrderBy { get; set; }

        public bool IsDescending { get; set; }

        public string RequestURL { get; set; }

        public string GetURL(EventSearchOrder orderBy, bool isDescending)
        {
            var temp = string.Empty;
            if (RequestURL.Contains("/?"))
            {
                temp = RequestURL;
            }
            else if (RequestURL.EndsWith("/"))
            {
                temp = RequestURL + "?";
            }
            else
            {
                temp = RequestURL + "/?";
            }

            temp = Regex.Replace(temp, "&?orderby=[a-zA-Z]*", "");
            var result = new StringBuilder(Regex.Replace(temp, "&?descending=[a-zA-Z]{4,5}", ""));

            result.Append(string.Format("&orderby={0}", orderBy));
            result.Append(string.Format("&descending={0}", isDescending));
            result.Replace("?&", "?");
            return result.ToString();
        }
    }

    public class EventModel 
    {
        public Event Event { get; set; }
        public Event Event_Local { get; set; }
    }
}
